package cn.woochen.comlib.jsbridge

import android.webkit.JavascriptInterface
import cn.woochen.comlib.util.ext.woochenLog

/**
 * JavascriptInterface基类(用户自定义可以继承这里或者直接重写)
 * @property callBacks
 */
abstract class BaseJavascriptInterface(private val callBacks: MutableMap<String, OnBridgeCallback>?) {

    @JavascriptInterface
    fun response(data: String?, callbackId: String?) {//js调用完native的方法后，js调用这个方法把数据交给native
        woochenLog("chromium->${data},callbackId：${callbackId}")
        callBacks?.remove(callbackId)?.onCallBack(data)
    }

    @JavascriptInterface
    abstract fun send(data: String?,responseId: String?)

}